package com.bawei.common.view

import android.content.Context
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView

/**
 * Author: Jason Zhang
 * Date: 2025/2/6
 * Desc: 自定义布局管理器，实现类似抖音页面切换效果
 */
class SnapPageLayoutManager constructor(context: Context): LinearLayoutManager(context){

    private val mSnapHelper = PagerSnapHelper()

    override fun onAttachedToWindow(view: RecyclerView?) {
        super.onAttachedToWindow(view)
        mSnapHelper.attachToRecyclerView(view) //将RecyclerView页面切换交给PagerSnapHelper管理
    }

}